using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Sedodream.Sudoku.Evaluators;

namespace Sedodream.Sudoku.Board
{
	[DebuggerDisplay("{ToString()}")]
	public class Move : IMove
	{
		#region Fields
		private IBoard board;
		private IPoint location;
		private int value;
		private bool forcedMove;
		private int moveScoreOLD;
		private IScore moveScore;
		private static int numMovesCreated = 0;
		#endregion

		#region Constructors
		public Move(IBoard board, IPoint location, int value)
		{
			this.board = board;
			this.location = location;
			this.value = value;

			//this.board.BoardData.BoardChanged +=new Sedodream.Sudoku.Events.BoardDataChanged(BoardData_BoardChanged);

			numMovesCreated++;
		}
		public Move(IBoard board, IPoint location, int value, bool forcedMove, int moveScore)
			: this(board,location,value)
		{
			this.forcedMove = forcedMove;
			this.moveScoreOLD = moveScore;
		}
		void BoardData_BoardChanged(object sender, Sedodream.Sudoku.Events.BoardChangedEventArgs args)
		{
			//This could be a way to always keep the move score up to date
			int debug = 3;
		}
		#endregion

		#region IMove Members

		public IBoard Board
		{
			get { return this.board; }
		}
		public IPoint Location
		{
			get { return this.location; }
		}
		public int Value
		{
			get { return this.value; }
		}
		public bool ForcedMove
		{
			get { return this.forcedMove; }
			set { this.forcedMove = value; }
		}
		public int MoveScoreOLD
		{
			get { return this.moveScoreOLD; }
			set { this.moveScoreOLD = value; }
		}
		public IScore MoveScore
		{
			get { return this.moveScore; }
			set { this.moveScore = value; }
		}
		#endregion

		//public override bool Equals(object obj)
		//{
		//    if (obj == null)
		//        return false;
		//    IMove otherMove = obj as IMove;
			
		//    if (otherMove == null)
		//        return false;

		//    //if(otherMove.


		//    return base.Equals(obj);
		//}

		public override string ToString()
		{
			if (location != null)
			{
				return string.Format("{0}:{1}", Location.ToString(), Value);
			}
			else
				return "[]";
		}
	}
}
